package org.zpmis.api.http;

import org.zpmis.api.business.CustomerPlanWebService;
import org.zpmis.common.base.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.zpmis.common.exception.BusinessException;
import org.zpmis.common.result.PlatformResult;
import org.zpmis.domain.customer.qo.AddCustomerPlanQo;
import org.zpmis.domain.customer.qo.EditCustomerPlanQo;
import org.zpmis.domain.customer.qo.CustomerPlanListQo;

import javax.annotation.Resource;

/**
* created with CodeGenerator
* description:
* @author  Yang
* date: 2021-6-2
* time: 14:48:50
*/
@RestController
@RequestMapping("/plan")
@Slf4j
public class CustomerPlanController extends BaseController{

    @Resource
    private CustomerPlanWebService customerPlanWebService;


    /**
     * 新增意向客户回访计划
     * @param addCustomerPlanQo
     * @return
     */
    @PostMapping("/addCustomerPlan")
    public PlatformResult addCustomerPlan(@RequestBody AddCustomerPlanQo addCustomerPlanQo){
        try {
            customerPlanWebService.addCustomerPlan(addCustomerPlanQo);
        } catch (BusinessException e) {
            log.error("[IntentionController]---addCustomerPlan--->BusinessException:",e);
            return PlatformResult.failure(e.getResultCode());
        } catch (Exception e) {
            log.error("[IntentionController]---addCustomerPlan--->Exception:",e);
            return PlatformResult.failure();
        }
        return PlatformResult.success();
    }

    /**
     * 修改意向客户回访计划
     * @param editCustomerPlanQo
     * @return
     */
    @PostMapping("/editCustomerPlan")
    public PlatformResult editCustomerPlan(@RequestBody EditCustomerPlanQo editCustomerPlanQo){
        try {
            customerPlanWebService.editCustomerPlan(editCustomerPlanQo);
        } catch (BusinessException e) {
            log.error("[IntentionController]---editCustomerPlan--->BusinessException:",e);
            return PlatformResult.failure(e.getResultCode());
        } catch (Exception e) {
            log.error("[IntentionController]---editCustomerPlan--->Exception:",e);
            return PlatformResult.failure();
        }
        return PlatformResult.success();
    }

    /**
     * 回访计划列表查询
     * @param planListQo
     * @return
     */
    @PostMapping("/customerPlanList")
    public PlatformResult customerPlanList(@RequestBody CustomerPlanListQo planListQo){
        try {
            return PlatformResult.success(customerPlanWebService.planList(planListQo));
        } catch (Exception e) {
            log.error("[IntentionController]---planList--->Exception:",e);
            return PlatformResult.failure();
        }
    }


}
